---
title: 章 9. Building and Installing a FreeBSD Kernel
prev: books/developers-handbook/partiii
next: books/developers-handbook/kerneldebug
showBookMenu: true
weight: 12
path: "/books/developers-handbook/"
---

[[kernelbuild]]
= Building and Installing a FreeBSD Kernel
:doctype: book
:toc: macro
:toclevels: 1
:icons: font
:sectnums:
:sectnumlevels: 6
:sectnumoffset: 9
:partnums:
:source-highlighter: rouge
:experimental:
:images-path: books/developers-handbook/

ifdef::env-beastie[]
ifdef::backend-html5[]
:imagesdir: ../../../../images/{images-path}
endif::[]
ifndef::book[]
include::shared/authors.adoc[]
include::shared/mirrors.adoc[]
include::shared/releases.adoc[]
include::shared/attributes/attributes-{{% lang %}}.adoc[]
include::shared/{{% lang %}}/teams.adoc[]
include::shared/{{% lang %}}/mailing-lists.adoc[]
include::shared/{{% lang %}}/urls.adoc[]
toc::[]
endif::[]
ifdef::backend-pdf,backend-epub3[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]
endif::[]

ifndef::env-beastie[]
toc::[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]

Being a kernel developer requires understanding of the kernel build process. To debug the FreeBSD kernel it is required to be able to build one. There are two known ways to do so:

The supported procedure to build and install a kernel is documented in the extref:{handbook}kernelconfig/[Building and Installing a Custom Kernel, kernelconfig-building] chapter of the FreeBSD Handbook.

[NOTE]
====
It is supposed that the reader of this chapter is familiar with the information described in the extref:{handbook}kernelconfig/[Building and Installing a Custom Kernel, kernelconfig-building] chapter of the FreeBSD Handbook. If this is not the case, please read through the above mentioned chapter to understand how the build process works.
====

[[kernelbuild-traditional]]
== Building the Faster but Brittle Way

Building the kernel this way may be useful when working on the kernel code and it may actually be faster than the documented procedure when only a single option or two were tweaked in the kernel configuration file. On the other hand, it might lead to unexpected kernel build breakage.

[.procedure]
====
. Run man:config[8] to generate the kernel source code:
+
[source,shell]
....
# /usr/sbin/config MYKERNEL
....

. Change into the build directory. man:config[8] will print the name of this directory after being run as above.
+
[source,shell]
....
# cd ../compile/MYKERNEL
....

. Compile the kernel:
+
[source,shell]
....
# make depend
# make
....

. Install the new kernel:
+
[source,shell]
....
# make install
....
====
